package com.jdojo.transform;

/**
 * @author zhufeifei
 * @date 2024-04-22 14:36
 */

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.transform.Rotate;
import javafx.stage.Stage;

public class RotateTest extends Application {
    public static void main(String[] args) {
        Application.launch(args);
    }

    @Override
    public void start(Stage stage) {
        Rectangle rect1 = new Rectangle(100, 50, Color.LIGHTGRAY);
        rect1.setStroke(Color.BLACK);
        Rectangle rect2 = new Rectangle(100, 50, Color.LIGHTGRAY);
        rect2.setStroke(Color.BLACK);
        rect2.setOpacity(0.5);
        // Apply a rotation on rect2. The rotation angle is 30 degree clockwise
        // (0, 0) is the pivot point
        Rotate rotate = new Rotate(30, 0, 0);
        rect2.getTransforms().addAll(rotate);
        Pane root = new Pane(rect1, rect2);
        root.setPrefSize(300, 80);
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.setTitle("Applying the Rotation Transformation");
        stage.show();
    }
}